<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <script src="../../../../res/js/jquery-3.4.1.min.js"></script>
    <script charset="utf-8" src="../../../../res/layui/layui.js"></script>
    <script src="../../../../res/js/Tools.js"></script>
    <link href="../../../../res/layui/css/layui.css" media="all" rel="stylesheet">
    <script charset="utf-8" src="../../../../res/js/login_common.js"></script>
    <style type="text/css">
        body {
            padding: 10px;
        }
        .title{
            font-size: 40px;
            font-weight: 600;
            width: 100%;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
<div class="title">个人信息</div>
<form action="" class="layui-form layui-form-pane" lay-filter="example">
    <input type="hidden" name="pkPersonnelId" id="pkPersonnelId" lay-verify="keyword">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">人员姓名</label>
            <div class="layui-input-inline" style="float: left">
                <input class="layui-input" id="personnelName" name="personnelName" disabled type="text">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">部门</label>
            <div class="layui-input-inline">
                <input  class="layui-input"  id="organizationId" disabled type="text">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">岗位</label>
            <div class="layui-input-inline">
                <input  class="layui-input"  id="organizationType"  disabled type="text">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-inline" >
                <input class="layui-input" id="personnelEmail" name="personnelEmail" type="text">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">办公电话</label>
            <div class="layui-input-inline" >
                <input  class="layui-input"  id="personnelPhone" name="personnelPhone" type="text">
            </div>
        </div>
    </div>
    <div class="layui-form-item" pane="">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-inline" >
            <input  name="personnelSex" disabled id="sex" title="男" type="radio" value="1" checked="">
            <input name="personnelSex" disabled title="女" type="radio" value="0">
        </div>

    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">登录账号</label>
            <div class="layui-input-inline" style="float: left">
                <input  class="layui-input"   id="personnelAccount" name="personnelAccount" type="text">
            </div>
        </div>



        <div class="layui-inline">
            <label class="layui-form-label">微信号</label>
            <div class="layui-input-inline" style="float: left">
                <input  class="layui-input" id="personnelWx" name="personnelWx" type="text">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">关键字</label>
            <div class="layui-input-inline" style="float: left">
                <input  class="layui-input" id="keyword" name="keyword" type="text"><span id="msg"></span>
            </div>
        </div>
    </div>
   <center> <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button></center>
</form>
<script>
    function ready() {
        url = getRootPath()+"OaPersonnelAction/getUser";
        $.ajax({
            //请求方式
            type: "GET",
            //请求的媒体类型
            contentType: "application/json;charset=UTF-8",
            //请求地址
            url: url,
            //数据，json字符串
            async: true,
            //请求成功
            success: function (res) {
                console.log(res);
                $("#pkPersonnelId").val(res.data.pkPersonnelId);
                $("#personnelName").val(res.data.personnelName);
                $("#organizationId").val(res.data.departmentName);
                $("#organizationType").val(res.data.postName);
                $("#personnelAccount").val(res.data.personnelAccount);
                $("#personnelEmail").val(res.data.personnelEmail);
                $("#personnelPhone").val(res.data.personnelPhone);
                $("#personnelWx").val(res.data.personnelWx);
                $("#keyword").val(res.data.keyword);
                if (res.data.personnelSex==0){
                    $("#personnelSex").val("男");
                }else {
                    $("#personnelSex").val("女");
                }
            }
        });
    }

    document.addEventListener("DOMContentLoaded", ready);
    layui.use(['form', 'layedit', 'laydate', 'layer'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        //监听提交
        form.on('submit(demo1)', function(data){
            var url=getRootPath() + "/OaPersonnelAction/addOrUpdate";
            let res=postAjax(url,data.field);
            console.log(res);
            if(res.code===1){

                alert('修改成功，信息将在下次登录后进行更新');
            }else{
                layer.msg("操作失败");
            }
            return false;
        });

        //重新渲染表单函数
        function renderForm() {
            layui.use('form', function () {
                var form = layui.form(); //高版本建议把括号去掉，有的低版本，需要加()
                form.render();
            });
        }
        form.render();
    });
</script>
</body>
</html>